Repository navigation
MLE-29978: Disable DTD processing when parsing server XML responses (CWE-827) - #1994
hmadala001 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Error-response parsing reuses a caller-configurable thread-local XML factory, so disabling namespace awareness can cause subsequent responses to lose their message, message code, and status text.
1 open issue
What changed in this PR
This PR hardens XML server-response parsing in the core Java client to address CWE-827 by reusing the existing secure XML factories.
Changes:
- Route four JAXB response handles through stream readers with DTD and external-entity processing disabled.
- Wrap stream-parser failures in
MarkLogicIOException. - Use the hardened document-builder factory for XML error responses.
| File | Description |
|---|---|
marklogic-client-api/src/main/java/com/marklogic/client/io/ValuesListHandle.java |
Harden values-list XML parsing. |
marklogic-client-api/src/main/java/com/marklogic/client/io/ValuesHandle.java |
Harden values XML parsing. |
marklogic-client-api/src/main/java/com/marklogic/client/io/TuplesHandle.java |
Harden tuple XML parsing. |
marklogic-client-api/src/main/java/com/marklogic/client/io/QueryOptionsListHandle.java |
Harden query-options-list XML parsing. |
marklogic-client-api/src/main/java/com/marklogic/client/impl/FailedRequest.java |
Use secure factory defaults for XML error responses. |
Review effort: Balanced
Use a fresh secure DOM builder for error parsing and avoid closing the query options input stream. Add a regression test for shared factory configuration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Response stream handling: Using XMLStreamReader with JAXB can leave response streams open, depending on the StAX implementation. This can lead to connection leaks. I suggest using a hardened SAX XMLReader with SAXSource to retain the previous behavior without adding an explicit close(). Tests: Please add server-independent tests to verify that FailedRequest and all four handles reject DOCTYPE payloads, valid XML still parses, and streams are properly closed. Failing checks: The copyright check and Jenkins build are failing. Five modified files also still have 2010-2025 copyright headers. |

No description provided.